<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>验证邮箱</title>
</head>
<body>
  <script>
    var email=prompt("请输入正确的邮箱地址：","hehe@qq.com");
    var at=email.indexOf("@");
    var dian=email.lastIndexOf(".");
    if (email!=null && email!=""){
         if (at<1 ||dian+2>=email.length){
            alert("电子邮箱地址格式输入错误！")
         } else if (at < dian){
           alert("电子邮箱格式输入正确！")
         }else {
           alert("电子邮箱地址格式输入错误！")
         }
    } else {
      alert("电子邮箱地址不能为空!");
    }
  </script>
</body>
</html>
